﻿@model IEnumerable<TeamCityMonitor.Models.BuildConfigurationStatistics>

<script type="text/javascript">

    $(document).ready(function () {
        $('#configindividualstats').dataTable({
            "bPaginate": false,
            "bLengthChange": false,
            "bFilter": false,
            "bSort": true,
            "bInfo": false,
            "bAutoWidth": false,
            "aaSorting": [[0, 'asc'], [1, 'asc']],
            "aoColumns": [
                            null,
                            null,
                            null,
                            null,
                            { "sType": 'percent' },
                            null,
                            { "sType": 'percent' },
                            null,
                            { "sType": 'percent' },
                            null,
                            { "sType": 'percent' }
                         ]            
        });

        jQuery.fn.dataTableExt.oSort['percent-asc'] = function (a, b) {
            var x = (a == "-") ? 0 : a.replace(/%/, "");
            var y = (b == "-") ? 0 : b.replace(/%/, "");
            x = x.replace(",", ".");
            y = y.replace(",", ".");
            x = parseFloat(x);
            y = parseFloat(y);
            return ((x < y) ? -1 : ((x > y) ? 1 : 0));
        };

        jQuery.fn.dataTableExt.oSort['percent-desc'] = function (a, b) {
            var x = (a == "-") ? 0 : a.replace(/%/, "");
            var y = (b == "-") ? 0 : b.replace(/%/, "");
            x = x.replace(",", ".");
            y = y.replace(",", ".");
            x = parseFloat(x);
            y = parseFloat(y);
            return ((x < y) ? 1 : ((x > y) ? -1 : 0));
        };
    });

</script>

<table id="configindividualstats">
    <thead>
        <tr>
            <th>Project Name</th>
            <th>Configuration Name</th>

            <th>Number of builds</th>

            <th>Successfull builds</th>
            <th>% of successfull builds</th>

            <th>Failure builds</th>
            <th>% of failure builds</th>

            <th>Error builds</th>
            <th>% of error builds</th>
            
            <th>Unknown builds</th>
            <th>% of unknown builds</th>
        </tr>
    </thead>
    @foreach (var item in Model) {
        <tr>
            <td>@Html.DisplayFor(modelItem => item.Project)</td>
            <td>@Html.DisplayFor(modelItem => item.Name)</td>

            <td>@Html.DisplayFor(modelItem => item.BuildCount)</td>

            <td>@Html.DisplayFor(modelItem => item.SuccessfullBuildCount)</td>
            <td>@Html.DisplayFor(modelItem => item.SuccessfullBuildPercentage)%</td>

            <td>@Html.DisplayFor(modelItem => item.FailureBuildCount)</td>
            <td>@Html.DisplayFor(modelItem => item.FailureBuildPercentage)%</td>

            <td>@Html.DisplayFor(modelItem => item.ErrorBuildCount)</td>
            <td>@Html.DisplayFor(modelItem => item.ErrorBuildPercentage)%</td>
            
            <td>@Html.DisplayFor(modelItem => item.UnknownBuildCount)</td>
            <td>@Html.DisplayFor(modelItem => item.UnknownBuildPercentage)%</td>
        </tr>
    }

</table>
